package com.lnsystem.model;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;

@Entity
@Table(name="STOCKMOVINGAVERAGE")
public class MovingAverage {
	
	@Id
	@Column(name="ID")
	@GeneratedValue(strategy=GenerationType.SEQUENCE, generator="STOCK_MOVING_AVERAGE_SEQUENCE")
	@SequenceGenerator(
		    name="STOCK_MOVING_AVERAGE_SEQUENCE",
		    sequenceName="STOCK_MOVING_AVERAGE_SEQUENCE",
		    allocationSize=20
		)
	private int id; 
	
	@Column
	private  int type; //0=SMA, 1=EMA
	
	@Column
	private int period; //50, 200 (for sma), 8,10 (for ema) etc..
	
	@Column
	private double runningSum;
	
	@ManyToOne(fetch = FetchType.LAZY,  cascade = {CascadeType.ALL})
	@JoinColumn(name = "STOCKDAILYID", nullable = false)
	private StockDailyData stockDailyData; 
	
	MovingAverage(){}

	
	public MovingAverage(int type, int period, double maValue) {
		super();
		this.type = type;
		this.period = period;
		this.maValue = maValue;

	}
	public MovingAverage(int type, int period, double maValue, double runningSum) {
		super();
		this.type = type;
		this.period = period;
		this.maValue = maValue;
		this.runningSum = runningSum;

	}

	double maValue;

	public int getType() {
		return type;
	}

	public void setType(int type) {
		this.type = type;
	}

	public int getPeriod() {
		return period;
	}

	public void setPeriod(int period) {
		this.period = period;
	}

	public double getMaValue() {
		return maValue;
	}

	public void setMaValue(double maValue) {
		this.maValue = maValue;
	}


	public double getRunningSum() {
		return runningSum;
	}


	public void setRunningSum(double runningSum) {
		this.runningSum = runningSum;
	}


	public int getId() {
		return id;
	}


	public void setId(int id) {
		this.id = id;
	}


	public StockDailyData getStockDailyData() {
		return stockDailyData;
	}


	public void setStockDailyData(StockDailyData stockDailyData) {
		this.stockDailyData = stockDailyData;
	}

	
}
